import React from 'react'
/**
 * 高阶组件 
 * @param {*} comp 组件
 * @returns 
 */
export default function withLog(Comp) {
  console.log(Comp)
   class LogWrappere extends React.Component{
    componentDidMount(){
      console.log(`日志：组件${Comp.name}被创建了${Date.now()}`)
    }
    componentWillUnmount(){
      console.log(`日志：组件${Comp.name}即将被销毁了${Date.now()}`)
    }
    render(){
      return <Comp {...this.props}/>
    }
  }
  
  return React.forwardRef((props,ref)=>{
    return <LogWrappere {...props}  forwardRef={ref}/>
  })
}
